﻿using System;
using System.Collections;

namespace GadgeteerLibrary
{
    /// <summary>
    /// Supported sensor types
    /// </summary>
    public enum SensorType : byte
    {
        temperatureHumidity = 1,
        light = 2,
        pulse = 3,
        gps = 4,
        accelerometer = 5,
        potentiometer = 6,
        barometer = 7,
        color = 8,
        compass = 9,
        current = 10,
        distance = 11,
        gas = 12,
        gyro = 13,
        moisture = 14,
        thermocouple = 15
    }

    /// <summary>
    /// Contains necessary sensor information
    /// </summary>
    public class Sensor
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public SensorType Type { get; set; }
        public string Make { get; set; }
        public string MeasureInterval { get; set; }
        public string SendingInterval { get; set; }
        public string FaultTolerance { get; set; }

        public Sensor(string sensorName, SensorType sensorType, string sensorMake,
            int measureInterval, int sendingInterval, int faultTolerance)
        {
            Name = sensorName;
            Type = sensorType;
            Make = sensorMake;
            MeasureInterval = measureInterval.ToString();
            SendingInterval = sendingInterval.ToString();
            FaultTolerance = faultTolerance.ToString();
            Id = string.Empty;
        }

        private Sensor()
        {

        }
    }

    /// <summary>
    /// Contains necessary device information
    /// </summary>
    public class Device
    {
        public string UserID { get; set; }
        public string Id { get; set; }
        public string Name { get; set; }
        public string Location { get; set; }
        public string Privacy { get; set; }
        public string Description { get; set; }

        private Device()
        {

        }

        public Device(string deviceID, string deviceName, string userID)
        {
            Id = deviceID;
            Name = deviceName;
            UserID = userID;
        }

        public Device(int deviceID, string deviceName)
        {
            Id = deviceID.ToString();
            Name = deviceName;
        }
    }

    /// <summary>
    /// Data collected from the sensor along with the timestamp for every data entry
    /// </summary>
    public class TimedData
    {
        public string DataTime { get; set; }
        public string FirstData { get; set;}
        public string SecondData { get; set; }
        public string ThirdData { get; set; }
        public string FourthData { get; set; }

        public TimedData(string dataTime, string firstData)
        {
            DataTime = dataTime;
            FirstData = firstData;
            SecondData = string.Empty;
            ThirdData = string.Empty;
            FourthData = string.Empty;
        }

        public TimedData(string dataTime, string firstData, string secondData)
        {
            DataTime = dataTime;
            FirstData = firstData;
            SecondData = secondData;
            ThirdData = string.Empty;
            FourthData = string.Empty;
        }

        public TimedData(string dataTime, string firstData, string secondData, 
            string thirdData)
        {
            DataTime = dataTime;
            FirstData = firstData;
            SecondData = secondData;
            ThirdData = thirdData;
            FourthData = string.Empty;
        }

        public TimedData(string dataTime, string firstData, string secondData, 
            string thirdData, string fourthData)
        {
            DataTime = dataTime;
            FirstData = firstData;
            SecondData = secondData;
            ThirdData = thirdData;
            FourthData = fourthData;
        }

        private TimedData()
        {

        }
    }

    /// <summary>
    /// Holds the device configuration informaton read from XML file 
    /// which can be downloaded from the web site
    /// </summary>
    public class AppSettings
    {
        public string UserID { get; set; }
        public string APIKey { get; set; }
        public string DeviceID { get; set; }
        public string DeviceName { get; set; }
    }
}
